#include <algorithm>
#include <iostream>
#define LL long long
using namespace std;

const int kMaxN = 110;
const int kMaxM = 110;
const LL kInf = 1e18;

LL f[kMaxN][kMaxN][kMaxM];
int c[kMaxN];
int p[kMaxN][kMaxM];

void Renew(LL& a, LL b) {
  a = min(a, b);
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> p[i][j];
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= m; l++) {
        f[i][j][l] = kInf;
      }
    }
  }
  f[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= m; l++) {
        if (f[i][j][l] == kInf) {
          continue;
        }
        if (c[i + 1] == 0) {
          for (int t = 1; t <= m; t++) {
            Renew(f[i + 1][j + (l != t)][t], f[i][j][l] + p[i + 1][t]);
          }
        } else {
          Renew(f[i + 1][j + (l != c[i + 1])][c[i + 1]], f[i][j][l]);
        }
      }
    }
  }
  LL ans = kInf;
  for (int i = 1; i <= m; i++) {
    ans = min(ans, f[n][k][i]);
  }
  cout << (ans == kInf ? -1 : ans) << "\n";
  return 0;
}